package com.panopset.net.ftp;


import static com.panopset.Util.*;

import java.io.IOException;
import java.net.Socket;

/**
 * java.net.Socket wrapper
 *
 * @author Karl Dinwiddie
 *
 */
public class AbstractSocket {
    private Socket socket;
    public final String host;
    public final int port;

    public AbstractSocket(String host, int port) {
        this.host = host;
        this.port = port;
    }

    public Socket getSocket() throws IOException {
        if (socket == null) {
            socket = new Socket(host, port);
        }
        return socket;
    }

    public void close() throws IOException {
        if (socket != null) {
            try {
                socket.close();
            } catch (IOException e) {
                log(e);
            }
            socket = null;
        }
    }
}
